package com.mxf.code.cases.topic;

import com.mxf.code.config.MessageSender;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author jaymin
 * 2021/1/2 15:32
 */
@Component
@AllArgsConstructor(onConstructor_ = {@Autowired})
public class TopicProducer {
    private MessageSender messageSender;

    public void sendMessage(String message, String topic) {
        messageSender.convertAndSend(TopicMQConfig.TOPIC_EXCHANGE_NAME, topic + "1", message);
    }
}